package com.intellagric.controller.module.agritech;

import com.intellagric.common.pojo.LayuiDataGridResult;
import com.intellagric.common.pojo.ResponseMessage;
import com.intellagric.common.utils.JsonUtils;
import com.intellagric.module.agritech.AgtAgritechVo;
import com.intellagric.pojo.AgtAgritech;
import com.intellagric.service.agritech.AgritechService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Author: cwq
 * @Date: 2019/2/22 19:28
 * @Description:
 */
@RequestMapping("/api/agt_agritech")
@Controller
public class AgritechController {

    @Autowired
    private AgritechService agritechService;

    @RequestMapping("/add")
    @ResponseBody
    public ResponseMessage add(AgtAgritech agritech) {
        return agritechService.addAgritech(agritech);
    }

    @RequestMapping("/delete")
    @ResponseBody
    public ResponseMessage delete(String id) {
        return agritechService.deleteAgritech(id);
    }

    @RequestMapping("/edit")
    @ResponseBody
    public ResponseMessage edit(AgtAgritech agritech) {
        return agritechService.editAgritech(agritech);
    }

    @RequestMapping("/{id}")
    @ResponseBody
    public AgtAgritech get(@PathVariable String id) {
        return agritechService.getAgritechById(id);
    }

    @RequestMapping("/list")
    @ResponseBody
    public LayuiDataGridResult getList() {
        return agritechService.getAgritechList();
    }

    @RequestMapping("/query")
    @ResponseBody
    public LayuiDataGridResult getListByVo(AgtAgritechVo agtAgritechVo, int page, int limit) {
        return agritechService.getAgritechListByVo(agtAgritechVo, page, limit);
    }

    @RequestMapping("/page")
    @ResponseBody
    public LayuiDataGridResult getPage(int page,int limit) {
        return agritechService.getAgritechByPage(page, limit);
    }
}
